﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using System.Reflection;
using log4net;

namespace AnyOffice.general.email
{
    public partial class delete : ModulePage
    {

        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);


        protected void Page_Load(object sender, EventArgs e)
        {
            int emailId = (Request.QueryString["email_id"] == null) ? 0 : int.Parse(Request.QueryString["email_id"].ToString());
            string str = (Request.QueryString["page"] == null) ? "1" : Request.QueryString["page"].ToString();
            string str2 = (Request.QueryString["box_type"] == null) ? "inbox" : Request.QueryString["box_type"].ToString();
            string str3 = (Request.QueryString["box_id"] == null) ? "0" : Request.QueryString["box_id"].ToString();
            try
            {
                EmailDao dao = new EmailDao();
                if (str2.ToLower() == "inbox")
                {
                    dao.Delete(base.Conn, emailId, EmailDao.DeleteType.Inbox, base.User.Identity.Name);
                }
                else
                {
                    dao.Delete(base.Conn, emailId, EmailDao.DeleteType.Outbox, base.User.Identity.Name);
                }
            }
            catch (Exception exception)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("", exception);
                }
            }
            base.CloseConn();
            if (str2.ToLower() == "inbox")
            {
                Response.Redirect("inbox.aspx?box_id=" + str3.ToString() + "&page=" + str);
            }
            else
            {
                Response.Redirect("outbox.aspx?page=" + str);
            }
        }

 

 

    }
}
